﻿using System.Data.Entity.ModelConfiguration;

namespace RakutenProxy.Model.Rakuten.Mapping
{
    public class CategoryMapping : EntityTypeConfiguration<Category>
    {
        public CategoryMapping()
        {
            HasKey(t => t.CategoryId);
            ToTable("Category");

            this.Property(t => t.CategoryName).IsRequired();

            this.HasMany(t => t.SubCategories).WithOptional(c => c.ParentCategory).HasForeignKey(c => c.ParentCategoryId);
        }
    }
}